package com.zhugang.week13.stack;

/**
 * @program algorithms
 * @description: dailyTemperatures
 * @author: chanzhugang
 * @create: 2022/11/11 00:44
 */
public class DailyTemperatures2 {

    /**
     * 739 每日温度
     * https://leetcode.cn/problems/daily-temperatures/
     *
     * @param temperatures
     * @return
     */
    public int[] dailyTemperatures(int[] temperatures) {
        /**
         * 思路：暴力求解，最简单
         * 比当前值大的第一个值，统计下标差; 两层for
         */
        int n = temperatures.length;
        int[] result = new int[n];
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                if (temperatures[j] > temperatures[i]) {
                    result[i] = j - i;
                    break;
                }
            }
        }
        return result;
    }
}